//
//  XGBaseViewController.m
//  YiCuiMiaoZhang
//
//  Created by Sings on 2017/6/22.
//  Copyright © 2018 益萃网络科技（中国）有限公司. All rights reserved.
//

#import "BZBaseViewController.h"
#import "Masonry.h"

@interface BZBaseViewController ()

@property (nonatomic, assign) BOOL noDataImageBring;

@end

@implementation BZBaseViewController

- (instancetype)initWithViewModel:(BaseControllerViewModel *)viewModel {
    if (self = [super init]) {
        if (_viewModel) {
            _viewModel.refresh = nil;
        }
        _viewModel = viewModel;
        BaseWeakObj(self);
        _viewModel.refresh = ^{
            [weakself refreshView];
        };
    }
    return self;
}

- (void)refreshView {
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.viewModel initialize];
    UIImageView *noDataImageV = [[UIImageView alloc] init];
    noDataImageV.image        = BZTHEME_IMAGE(skin_empty_nodata_create_img);
    noDataImageV.alpha        = 0.;
    noDataImageV.contentMode  = UIViewContentModeCenter;
    [self.view addSubview:noDataImageV];
    self.noDataImageV = noDataImageV;
    [noDataImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.view.mas_centerY).offset(-40);
        //        make.top.equalTo(self.view.mas_top).offset(180);
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.width.height.mas_equalTo(150);
    }];

    UIImageView *noDataTwoImageV = [[UIImageView alloc] init];
    noDataTwoImageV.image        = BZTHEME_IMAGE(skin_empty_nodata_img);
    noDataTwoImageV.alpha        = 0.;
    noDataTwoImageV.contentMode  = UIViewContentModeCenter;
    [self.view addSubview:noDataTwoImageV];
    self.noDataTwoImageV = noDataTwoImageV;
    [noDataTwoImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.view.mas_centerY).offset(-40);
        //        make.top.equalTo(self.view.mas_top).offset(180);
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.width.height.mas_equalTo(150);
    }];
    UIImageView *noDataRightImageV = [[UIImageView alloc] init];
    noDataRightImageV.image        = BZTHEME_IMAGE(skin_empty_nodata_create_img);
    noDataRightImageV.alpha        = 0.;
    noDataRightImageV.contentMode  = UIViewContentModeCenter;
    [self.view addSubview:noDataRightImageV];
    self.noDataRightImageV = noDataRightImageV;
    [noDataRightImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.view.mas_centerY).offset(-40);
        //        make.top.equalTo(self.view.mas_top).offset(180);
        make.centerX.mas_equalTo(self.view.mas_centerX).offset(50);
        make.width.height.mas_equalTo(120);
    }];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    if (!self.noDataImageBring) {
        self.noDataImageBring = YES;
        [self.view bringSubviewToFront:self.noDataImageV];
        [self.view bringSubviewToFront:self.noDataTwoImageV];
        [self.view bringSubviewToFront:self.noDataRightImageV];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)presentAnimation {
}

- (void)dismissAnimation {
}

@end
